#ifndef SPRINGAXIS_H
#define SPRINGAXIS_H

#include "Entity.h"
#include "Affector.h"

/*
 The SpringAxis object can be visualized as an infinite line which
 pulls or pushes entities in a direction perpendicular to
 itself. It has a spring constant and an equilibrium length,
 but these can also be overridden and specified for each
 individual entity it affects by using the customAffect
 method. A SpringAxis is defined by a point and a direction,
 and is an entity itself, and can therefore be affected by
 forces like gravity or SpringRoots. SpringAxes that are
 parallel can predictably affect one another, but those
 that are not will behave improperly since forces are
 applied to the point that is part of the definition of
 a SpringAxis. Further, the springForce method cannot be
 predictably used between non-parallel SpringAxes. Radial
 forces such as gravity and SpringRoots, however, can safely be applied
 to SpringAxes since any force can be split into a component along the axis
 and along the perpendicular, and the perpendicular component
 only depends on the perpendicular distance between the entity
 and the SpringAxis. No matter where the point that
 defines the SpringAxis lies, the same perpendicular component
 will result. Finally, because the perpendicular distance
 between the SpringAxis and the entities it affects is all
 that matters in determining how those entities move, it
 does not matter how far along its own axis the point
 defining the SpringAxis is moved. It will still affect
 entities in the same way.
 
 NOTE: the radian parameter is handled in the code as the
 strict mathematical definition; that is, as the radians
 increase, the angle rotates counter clockwise. The reverse
 Y-coordinate of SDL (increasing Y-axis moves downward) has
 been taken into account.
 */

class SpringAxis : public Entity, public Affector
{
private:
	Vec2d dir;
	
public:
	float k;
	float length;
	
	SpringAxis(Vec2d pos, Vec2d dir);
	SpringAxis(Vec2d pos, Vec2d dir, float k, float length);
	SpringAxis(Vec2d pos, float radians, float k, float length);
	void affect(Entity* e);
	void customAffect(Entity* e, float k, float length);
	void setDirection(float radians);
	float getDirection();
};

#endif